import { createRouter, createWebHashHistory } from 'vue-router';

const routes = [
  {
    path: '/',
    name: 'Home',
    alias: "/home,",
    component: () => import('../views/page1_shouye/Home.vue')
  },
  {
    path: '/load',
    component: () => import('../views/page2/load.vue')
  },
  {
    path: '/caifu',
    component: () => import('../views/page3/caifu.vue')
  },
  {
    path: '/map',
    component: () => import('../views/page4/map.vue')
  },
  {
    path: '/test',
    component: () => import('../views/page5/App.vue')
  }
  ,
  {
    path: '/baogao',
    component: () => import('../views/page6/caifubaogao.vue')
  }
  ,
  //  {
  //    path: '/turn',
  //    component: () => import('../views/page6/trun.vue')
  // },
  {
    path: '/anniu',
    component: () => import('../views/page6/anniu.vue')
  },

  {
    path: '/axis',
    component: () => import('../views/page_axis/axis.vue')
  },
  {
    path: '/community',
    component: () => import('../views/page_community/community.vue'),
  },
  {
    path: '/pick',
    component: () => import('../views/lzb/Pick.vue')
  },
  {
    path: '/ProductDetails',
    component: () => import('../views/lzb_2/Product Details.vue')
  },
  {
    path: '/ProductDetails1',
    component: () => import('../views/lzb_2/Product Details1.vue')
  },
  {
    path: '/ProductDetails2',
    component: () => import('../views/lzb_2/Product Details2.vue')
  },
  {
    path: '/ProductDetails3',
    component: () => import('../views/lzb_2/Product Details3.vue')
  },
  {
    path: '/RiskIndex',
    component: () => import('../views/lzb_3/RiskIndex.vue')
  },
  {
    path: '/Risktest',
    component: () => import('../views/lzb_3/Risktest.vue')
  },
  {
    path: '/Riskend',
    component: () => import('../views/lzb_3/Riskend.vue')
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes
});

// 全局路由守卫
router.beforeEach((to, from, next) => {
  let token = localStorage.getItem('token');
  if (to.meta.needLogin) {
    // if (token) {
    //   next();
    // } else {
    //   next('/login'); // 假设 '/login' 是登录页面的路径
    // }
  } else {
    next();
  }
});

export default router;
